package cn.kgm.nio;

import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

public class MappedChanalBuferTest {
    private final static String nioUrl = "niofile/";

    public static void main(String[] args) throws Exception{
        RandomAccessFile file  = new RandomAccessFile(nioUrl + "input.txt","rw");
        FileChannel channel = file.getChannel();
        // 5 代表长度，可选参数为 0,1,2,3,4
        MappedByteBuffer map = channel.map(FileChannel.MapMode.READ_WRITE, 0, 5);
        map.put(0,(byte)9);
        file.close();
        System.out.println("sucess");
    }
}
